home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Util / cli / Entries.lha / Entries / Entries.s < prev    next >
Text File  |  2003-12-26  |  22KB  |  882 lines

  1. *****************************************************************************
  2. *                                        *
  3. *    PROGRAM: Entries                            *
  4. *    VERSION: 1.7                                *
  5. *   SOURCE CODE: 29 (26.12.03)                            *
  6. *       DATE: 2.7.2003 - 22.7.2003                        *
  7. *      LANGUAGE: Assembler (DevPac V3.14)                    *
  8. *     SYSTEM: A1200    KS 40.68 WB 40.42 2MB chip 64MB fast 68030/50mhz    *
  9. *                                        *
  10. *     AUTHOR: Joerg Riemer 14167 Berlin/SchottmuellerStr.107/Germany        *
  11. *      EMAIL: joerg_riemer@freenet.de / mission@cs.tu-berlin.de        *
  12. *                                        *
  13. *    COMMENT:                                 *
  14. *                                        *
  15. *      TEMPLATE: PATTERN,ALL/S,NOSTAT/S,MARKEMPTY/S,QUICK/S,LARGESTFILE/S   *
  16. *                                        *
  17. *****************************************************************************
  18.  
  19. *        opt    d+,ow2-
  20.  
  21. BSS_Section    set    1
  22.  
  23. *****************************************************************************
  24.  
  25.     output    ram:Entries
  26.  
  27. ************************************************ exec definitions ***********
  28.  
  29. _LVOOpenLibrary        equ    -552
  30. _LVOCloseLibrary    equ    -414
  31.  
  32. ************************************************ dos definitions ************
  33.  
  34. _LVOWrite        equ    -048
  35. _LVOOutput        equ    -060
  36. _LVOLock        equ    -084
  37. _LVOUnLock        equ    -090
  38. _LVOInfo        equ    -114
  39. _LVOIoErr        equ    -132
  40. _LVOFPutC        equ    -312
  41. _LVOFPuts        equ    -342
  42. _LVOSetIoErr        equ    -462
  43. _LVOPrintFault        equ    -474
  44. _LVOIsFileSystem    equ    -708
  45. _LVOReadArgs        equ    -798
  46. _LVOFreeArgs        equ    -858
  47. _LVOMatchFirst        equ    -822
  48. _LVOMatchNext        equ    -828
  49. _LVOMatchEnd        equ    -834
  50. _LVOVPrintf        equ    -954
  51.  
  52. ap_BreakBits        equ    $008
  53. ap_Flags        equ    $010
  54. ap_Strlen        equ    $012
  55. ap_Info            equ    $014
  56.  
  57. fib_DirEntryType    equ    $004
  58. fib_EntryType        equ    $078
  59. fib_Size        equ    $07C
  60. fib_NumBlocks        equ    $080
  61.  
  62. RDA_SIZEOF        equ    $020
  63. RDA_ExtHelp        equ    $018
  64.  
  65. APB_DOWILD        equ    $000
  66. APB_ITSWILD        equ    $001
  67. APB_DODIR        equ    $002
  68. APB_DIDDIR        equ    $003
  69. APB_DODOT        equ    $005
  70.  
  71. ACCESS_READ        equ    -2
  72.  
  73. SIGBREAKB_CTRL_C    equ    $00C
  74. SIGBREAKB_CTRL_D    equ    $00D
  75. SIGBREAKB_CTRL_E    equ    $00E
  76. SIGBREAKB_CTRL_F    equ    $00F
  77.  
  78. ************************************************ icon definitions ***********
  79.  
  80. _LVOGetDiskObject    equ    -078
  81. _LVOPutDiskObject    equ    -084
  82. _LVOFreeDiskObject    equ    -090
  83.  
  84. WBPROJECT        equ    $004
  85. do_Type            equ    $030
  86. do_DefaultTool        equ    $032
  87.  
  88. ************************************************ bss datas ******************
  89.  
  90. Anchorpath    rs.b    280            ;size_of anchorpath
  91. PathName    rs.b    256            ;size_of ap_strlen (pathname)
  92.  
  93.         rs.l    1            ;eof
  94.  
  95. BFName        rs.b    256            ;path/filename biggest file
  96.  
  97. DOSBase        rs.l    1            ;ptr. base of library
  98.  
  99. ArgArray    rs.l    0            ;argarray
  100. Pattern        rs.l    1            ;argarray ptr. pattern
  101. All        rs.l    1            ;flag (print subdir entries)
  102. NoStat        rs.l    1            ;flag (don't print result)
  103. MarkEmpty    rs.l    1            ;flag (mark empty files)
  104. Quick        rs.l    1            ;flag (don't print entries)
  105. BiggestFile    rs.l    1            ;flag (print biggest file)
  106.  
  107. RDArgs        rs.l    1            ;ptr. rdargs structure
  108. RCode1        rs.l    1            ;errorcode -> rc
  109. RCode2        rs.l    1            ;errorcode -> result2
  110.  
  111. FCount        rs.l    2            ;# of files
  112. EFiles        rs.l    2            ;# of empty files
  113. BigFile        rs.l    2            ;# of files with extensions
  114. FileSize    rs.l    2            ;filesize total
  115. HBlocks        rs.l    2            ;# of headerblocks
  116. DBlocks        rs.l    2            ;# of datablocks
  117. EBlocks        rs.l    2            ;# of extensionblocks
  118. DCount        rs.l    2            ;# of directories
  119. TotalBlocks    rs.l    2            ;# of total blocks
  120. BlockSize    rs.l    2            ;physical blocksize
  121. TotalSize    rs.l    2            ;total size used
  122. BFSize        rs.l    2            ;size of biggest file
  123.  
  124. InfoData    rs.l    0            ;InfoData returned by Info()
  125. NumSoftErrs    rs.l    1
  126. UnitNum        rs.l    1
  127. DiskState    rs.l    1
  128. Blocks        rs.l    1
  129. BlocksUsed    rs.l    1
  130. BytesPerBlock    rs.l    1
  131. DiskType    rs.l    1
  132. VolumeNode    rs.l    1
  133. InUse        rs.l    1
  134.  
  135. ExtSize        rs.l    1            ;extension size in bytes
  136. ExtBlocks    rs.l    1            ;# of ext. entries per block
  137.  
  138. NoSize        rs.l    1            ;flag (curr. file is empty)
  139. LEDBit        rs.l    1            ;powerled status
  140.  
  141. RDAStruct    rs.b    RDA_SIZEOF        ;rdargs data structure
  142.  
  143. BSS_Size    rs.b    0            ;bss_size over all
  144.  
  145. *****************************************************************************
  146.  
  147. Start        movem.l    D1-D7/A0-A6,-(SP)    ;save registers
  148.  
  149.         if    BSS_Section        ;check assembler condition
  150.  
  151.         movea.l    Start-4(pc),A5        ;get bss_section
  152.         addq.l    #1,A5            ;skip pointer (next segment)
  153.         adda.l    A5,A5            ;convert bpcl_pointer
  154.         adda.l    A5,A5            ;to real_address
  155.  
  156.         elseif                ;otherwise
  157.  
  158.         lea    DataBase(pc),A5        ;set working area
  159.  
  160.         endc                ;end condition
  161.  
  162. ************************************************ open libraries *************
  163.  
  164.         moveq    #20,D0            ;failat level
  165.         move.l    D0,RCode1(A5)        ;preset error (no library)
  166.  
  167.         movea.l    4.w,A6            ;set EXEC to call a function
  168.  
  169.         moveq    #37,D0            ;required library version
  170.         lea    DOSName(pc),A1        ;set library name
  171.         jsr    _LVOOpenLibrary(A6)    ;use EXEC to (openlibrary)
  172.         move.l    D0,DOSBase(A5)        ;save base
  173.  
  174.         beq.b    CloseLibs        ;branch if not open
  175.  
  176. *****************************************************************************
  177.  
  178.         bsr.b    Main
  179.  
  180. ************************************************ close libraries ************
  181.  
  182. CloseLibs    movea.l    4.w,A6            ;set EXEC to call a function
  183.  
  184. CloseDOS    move.l    DOSBase(A5),D1        ;get base_ptr
  185.         beq.b    ExitDOS            ;branch when not open
  186.         movea.l    D1,A1            ;set base_ptr
  187.         jsr    _LVOCloseLibrary(A6)    ;use EXEC to (closelibrary)
  188.  
  189. ExitDOS        move.l    RCode1(A5),D0        ;set returncode
  190.         movem.l    (SP)+,D1-D7/A0-A6    ;restore registers
  191.         rts                ;go back (shell)
  192.  
  193. *****************************************************************************
  194.  
  195. DOSName        dc.b    "dos.library",0
  196.  
  197. *****************************************************************************
  198.  
  199. version    dc.b "$VER: Entries 1.7 29 (26.12.2003) by joerg riemer jul'03",0
  200.  
  201. *****************************************************************************
  202.  
  203.         cnop    0,4
  204.  
  205. *****************************************************************************
  206.  
  207. Main        clr.l    RCode1(A5)        ;clear returncode
  208.  
  209.         bsr    ReadArgs        ;q0 read user_arguments
  210.         bsr    CheckArgs        ;q0 check user_arguments
  211.         bsr    IsFileSystem        ;q0 check for valid filesystem
  212.         bsr    InitAPath        ;prepare anchorpath
  213.         bsr    MatchFirst        ;search for filename
  214.         bsr    GetDiskInfo
  215.         bsr    GetLEDBit
  216.  
  217. *****************************************************************************
  218.  
  219.         movea.l    DOSBase(A5),A6        ;set dos_base
  220.         jsr    _LVOOutput(A6)        ;search output_handle
  221.         move.l    D0,D7            ;save output
  222.  
  223. ************************************************
  224.  
  225.         lea    PathName(A5),A2        ;get filename to print
  226.         lea    Anchorpath(A5),A3    ;get anchorpath structure
  227.         lea    ap_Info(A5),A4        ;get fileinfoblock
  228.  
  229.         btst    #APB_ITSWILD,ap_Flags(A5)
  230.         beq.b    .skip
  231.  
  232.         bchg    #1,$bfe001
  233.  
  234. .skip        tst.b    Quick(A5)        ;do all Quick ?
  235.         bne    DoQuick            ;branch if so
  236.  
  237. ************************************************
  238.  
  239. .Loop        moveq    #1,D2
  240.  
  241.         tst.l    fib_DirEntryType(A4)    ;type = dir ?
  242.         bmi.b    .skip1            ;branch if not
  243.  
  244.         bclr    #APB_DIDDIR,ap_Flags(A5)
  245.         bne    .MatchNext
  246.  
  247.         add.l    D2,DCount(A5)        ;# of directories
  248.  
  249.         bchg    #1,$bfe001
  250.  
  251.         tst.l    All(A5)
  252.         beq.b    .skip2
  253.  
  254.         bset    #APB_DODIR,ap_Flags(A5)
  255.  
  256.         bra.b    .skip2
  257.  
  258. .skip1        add.l    D2,HBlocks(A5)        ;# of headerblocks
  259.  
  260.         move.l    fib_Size(A4),D0
  261.         seq    NoSize(A5)
  262.         beq.b    .skip2
  263.  
  264.         tst.l    BiggestFile(A5)
  265.         beq.b    .skip4
  266.  
  267.         cmp.l    BFSize(A5),D0
  268.         blt.b    .skip4
  269.  
  270.         move.l    D0,BFSize(A5)
  271.  
  272.         move.l    A2,A0
  273.         lea    BFName(A5),A1
  274. .copyname    move.l    (A0)+,(A1)+        ;copies max. 256 bytes
  275.         bne.b    .copyname
  276.         
  277. .skip4        add.l    D2,FCount(A5)        ;# of files
  278.         add.l    D2,TotalBlocks(A5)
  279.         add.l    D0,FileSize(A5)
  280.  
  281.         cmp.l    ExtSize(A5),D0
  282.         ble.b    .skip3
  283.  
  284.         add.l    D2,BigFile(A5)
  285.  
  286.         move.l    ExtSize(A5),D1
  287.         move.l    ExtBlocks(A5),D2
  288.         neg.l    D2
  289. .CalcExtBlocks    addq.l    #1,EBlocks(A5)
  290.         add.l    ExtBlocks(A5),D2
  291.         sub.l    D1,D0
  292.         bcc.b    .CalcExtBlocks
  293.  
  294.         add.l    D2,DBlocks(A5)
  295.         add.l    D2,TotalBlocks(A5)
  296.  
  297.         add.l    D1,D0
  298.  
  299. .skip3        move.l    BytesPerBlock(A5),D1
  300.         moveq    #0,D2
  301. .CalcFileBlocks    addq.l    #1,D2
  302.         sub.l    D1,D0
  303.         bcc.b    .CalcFileBlocks
  304.         add.l    D2,DBlocks(A5)
  305.  
  306. .skip2        add.l    D2,TotalBlocks(A5)
  307.  
  308. ******************* print path/filename ********
  309.  
  310. .PrintFName    move.l    D7,D1            ;set output
  311.         move.l    A2,D2            ;get filename to print
  312.         jsr    _LVOFPuts(A6)        ;use dos to fputs
  313.  
  314. ************************************************
  315.  
  316.         tst.b    NoSize(A5)
  317.         beq.b    .PrintNLine
  318.  
  319.         tst.b    MarkEmpty(A5)
  320.         beq.b    .PrintNLine
  321.  
  322.         move.l    D7,D1
  323.         lea    EString(pc),A1
  324.         move.l    A1,D2
  325.         jsr    _LVOFPuts(A6)
  326.         
  327. ******************* print newline character ****
  328.  
  329. .PrintNLine    move.l    D7,D1            ;set output
  330.         moveq    #$A,D2            ;set char. to print
  331.         jsr    _LVOFPutC(A6)        ;use dos to fputc
  332.  
  333. ******************* matchnext pattern **********
  334.  
  335. .MatchNext    move.l    A3,D1            ;get anchorpath structure
  336.         jsr    _LVOMatchNext(A6)    ;use dos to matchnext
  337.         move.l    D0,D1            ;get return_code
  338.         beq    .Loop            ;loop again when ok
  339.  
  340.         bra    Quit2
  341.  
  342. *****************************************************************************
  343.  
  344. DoQuick
  345.  
  346. .Loop        moveq    #1,D2
  347.  
  348.         tst.l    fib_DirEntryType(A4)    ;type = dir ?
  349.         bmi.b    .skip1            ;branch if not
  350.  
  351.         bclr    #APB_DIDDIR,ap_Flags(A5)
  352.         bne    .MatchNext
  353.  
  354.         add.l    D2,DCount(A5)        ;# of directories
  355.  
  356.         bchg    #1,$bfe001
  357.  
  358.         tst.l    All(A5)
  359.         beq.b    .skip2
  360.  
  361.         bset    #APB_DODIR,ap_Flags(A5)
  362.  
  363.         bra.b    .skip2
  364.  
  365. .skip1        add.l    D2,HBlocks(A5)        ;# of headerblocks
  366.  
  367.         move.l    fib_Size(A4),D0
  368.         seq    NoSize(A5)
  369.         beq.b    .skip2
  370.  
  371.         tst.l    BiggestFile(A5)
  372.         beq.b    .skip4
  373.  
  374.         cmp.l    BFSize(A5),D0
  375.         blt.b    .skip4
  376.  
  377.         move.l    D0,BFSize(A5)
  378.  
  379.         move.l    A2,A0
  380.         lea    BFName(A5),A1
  381. .copyname    move.l    (A0)+,(A1)+        ;copies max. 256 bytes
  382.         bne.b    .copyname
  383.  
  384. .skip4        add.l    D2,FCount(A5)        ;# of files
  385.         add.l    D2,TotalBlocks(A5)
  386.         add.l    D0,FileSize(A5)
  387.  
  388.         cmp.l    ExtSize(A5),D0
  389.         ble.b    .skip3
  390.  
  391.         add.l    D2,BigFile(A5)
  392.  
  393.         move.l    ExtSize(A5),D1
  394.         move.l    ExtBlocks(A5),D2
  395.         neg.l    D2
  396. .CalcExtBlocks    addq.l    #1,EBlocks(A5)
  397.         add.l    ExtBlocks(A5),D2
  398.         sub.l    D1,D0
  399.         bcc.b    .CalcExtBlocks
  400.  
  401.         add.l    D2,DBlocks(A5)
  402.         add.l    D2,TotalBlocks(A5)
  403.         add.l    D1,D0
  404.  
  405. .skip3        move.l    BytesPerBlock(A5),D1
  406.         moveq    #0,D2
  407. .CalcFileBlocks    addq.l    #1,D2
  408.         sub.l    D1,D0
  409.         bcc.b    .CalcFileBlocks
  410.         add.l    D2,DBlocks(A5)
  411.  
  412. .skip2        add.l    D2,TotalBlocks(A5)
  413.  
  414. ************************************************
  415.  
  416.         tst.b    NoSize(A5)
  417.         beq.b    .MatchNext
  418.  
  419.         tst.b    MarkEmpty(A5)
  420.         beq.b    .MatchNext
  421.  
  422.         not.b    NoSize(A5)
  423.  
  424. ******************* print path/filename ********
  425.  
  426. .PrintFName    move.l    D7,D1            ;set output
  427.         move.l    A2,D2            ;get filename to print
  428.         jsr    _LVOFPuts(A6)        ;use dos to fputs
  429.  
  430. ******************* print newline character ****
  431.  
  432. .PrintNLine    move.l    D7,D1            ;set output
  433.         moveq    #$A,D2            ;set char. to print
  434.         jsr    _LVOFPutC(A6)        ;use dos to fputc
  435.  
  436. ******************* matchnext pattern **********
  437.  
  438. .MatchNext    move.l    A3,D1            ;get anchorpath structure
  439.         jsr    _LVOMatchNext(A6)    ;use dos to matchnext
  440.         move.l    D0,D1            ;get return_code
  441.         beq    .Loop            ;loop again when ok
  442.  
  443. *****************************************************************************
  444.  
  445. Quit2        cmp.w    #232,D1            ;check for 'no more entries'
  446.         bne    Error5            ;branch if not
  447.  
  448.         move.l    #205,D1            ;preset 'object not found'
  449.         move.l    FCount(A5),D0        ;found some files ?
  450.         or.l    DCount(A5),D0        ;found some dirs ?
  451.         beq    Error5            ;branch if not
  452.  
  453.         tst.l    NoStat(A5)        ;print statistic ?
  454.         bne.b    Quit0            ;
  455.  
  456.         bsr.b    PrintResult        ;print some information
  457.  
  458. Quit0        bsr    MatchEnd        ;close matchnext() function
  459.         bsr    FreeArgs        ;free memory (readargs)
  460.         bsr    SetLEDBit
  461.  
  462.         rts                ;go back
  463.  
  464. *****************************************************************************
  465.  
  466.         cnop    0,4
  467.  
  468. *****************************************************************************
  469.  
  470. GetLEDBit    move.b    $bfe001,D0
  471.         andi.b    #%00000010,D0
  472.         move.b    D0,LEDBit(A5)
  473.         rts
  474.  
  475. *****************************************************************************
  476.  
  477.         cnop    0,4
  478.  
  479. *****************************************************************************
  480.  
  481. SetLEDBit    move.b    LEDBit(A5),D1
  482.         move.b    $bfe001,D0
  483.         andi.b    #%11111101,D0
  484.         eor.b    D1,D0
  485.         move.b    D0,$bfe001
  486.         rts
  487.  
  488. *****************************************************************************
  489.  
  490.         cnop    0,4
  491.  
  492. ************************************************ print result  **************
  493.  
  494. PrintResult    move.l    TotalBlocks(A5),D0    ;get # of blocks used
  495.         move.l    BlockSize(A5),D1    ;get blocksize
  496.         moveq    #0,D2            ;prepare register
  497.  
  498. .CalcTSize    add.l    D1,D2            ;calc. totalsize
  499.         subq.l    #1,D0            ;calc. totalsize
  500.         bne.b    .CalcTSize        ;calc. totalsize
  501.  
  502.         move.l    D2,TotalSize(A5)    ;save result
  503.  
  504.         lea    RString00(pc),A3    ;get formatstring
  505.         lea    -12(A3),A3        ;init. offset
  506.  
  507.         lea    DecTab(pc),A0        ;get count of digits
  508. .loop        lea    12(A3),A3        ;get count of digits
  509.         cmp.l    (A0)+,D2        ;get count of digits
  510.         blt.b    .loop            ;get count of digits
  511.  
  512. ************************************************
  513.  
  514.         move.l    HBlocks(A5),D0        ;calc. empty files
  515.         sub.l    FCount(A5),D0        ;calc. empty files
  516.         move.l    D0,EFiles(A5)        ;calc. empty files
  517.  
  518. ************************************************
  519.  
  520. PrintResult1    lea    RString01(pc),A4    ;get first string
  521.         lea    FCount(A5),A2        ;get ptr. (array of values)
  522.  
  523. .loop        move.l    A3,D1            ;set formatstring
  524.         move.l    A2,D2            ;set datastream
  525.         move.l    A4,4(A2)        ;set stringptr.
  526.         jsr    _LVOVPrintf(A6)        ;use dos to VPrintf
  527.         lea    8(A2),A2        ;get next array of values
  528.         lea    28(A4),A4        ;get next string
  529.         tst.b    (A4)            ;anything to print
  530.         bne.b    .loop            ;do if so
  531.  
  532.         tst.l    BiggestFile(A5)
  533.         beq.b    .skip
  534.  
  535.         tst.l    BFSize(A5)
  536.         beq.b    .skip
  537.  
  538.         addq.l    #1,A4
  539.         
  540.         move.l    A3,D1            ;set formatstring
  541.         move.l    A2,D2            ;set datastream
  542.         move.l    A4,4(A2)        ;set stringptr.
  543.         jsr    _LVOVPrintf(A6)        ;use dos to VPrintf
  544.  
  545. ******************* print path/filename ********
  546.  
  547. .PrintFName    move.l    D7,D1            ;set output
  548.         lea    BFName(A5),A2
  549.         move.l    A2,D2            ;get filename to print
  550.         jsr    _LVOFPuts(A6)        ;use dos to fputs
  551.  
  552. ******************* print newline character ****
  553.  
  554. .PrintNLine    move.l    D7,D1            ;set output
  555.         moveq    #$A,D2            ;set char. to print
  556.         jsr    _LVOFPutC(A6)        ;use dos to fputc
  557.  
  558. .skip        rts                ;go back
  559.         
  560. *****************************************************************************
  561.  
  562. DecTab        dc.l    1000000000
  563.         dc.l    100000000
  564.         dc.l    10000000
  565.         dc.l    1000000
  566.         dc.l    100000
  567.         dc.l    10000
  568.         dc.l    1000
  569.         dc.l    100
  570. *        dc.l    10
  571. *        dc.l    1
  572.  
  573.  
  574. RString00    dc.b    " %13lU %s",$A,0,0
  575.         dc.b    " %11lU %s",$A,0,0
  576.         dc.b    " %10lU %s",$A,0,0
  577.         dc.b    " %9lU %s ",$A,0,0
  578.         dc.b    " %7lU %s ",$A,0,0
  579.         dc.b    " %6lU %s ",$A,0,0
  580.         dc.b    " %5lU %s ",$A,0,0
  581.         dc.b    " %3lU %s ",$A,0,0
  582.  
  583. RString01    dc.b    "files                    ",0,0,0
  584. RString02    dc.b    "empty files              ",0,0,0
  585. RString03    dc.b    "files with extension     ",0,0,0
  586. RString04    dc.b    "bytes filesize total     ",0,0,0
  587. RString05    dc.b    "headerblocks             ",0,0,0
  588. RString06    dc.b    "datablocks               ",0,0,0
  589. RString07    dc.b    "extensionblocks          ",0,0,0
  590. RString08    dc.b    "directories              ",0,0,0
  591. RString09    dc.b    "diskblocks used total    ",0,0,0
  592. RString10    dc.b    "bytes per block          ",0,0,0
  593. RString11    dc.b    "bytes used total         ",0,0,0,0
  594.  
  595. RString12    dc.b    "bytes for largest file   ",0,0,0
  596.  
  597. EString        dc.b    "  EMPTY-FILE",0
  598.  
  599. *****************************************************************************
  600.  
  601.         cnop    0,4
  602.  
  603. ************************************************ free memory matchfirst/next
  604.  
  605. MatchEnd    lea    Anchorpath(A5),A1    ;get anchorpath structure
  606.         tst.l    (A1)
  607.         beq.b    .skip
  608.         move.l    A1,D1            ;prepare matchend
  609.         movea.l    DOSBase(A5),A6        ;set dos_base
  610.         jsr    _LVOMatchEnd(A6)    ;use dos for matchend
  611. .skip        rts                ;go back
  612.  
  613. *****************************************************************************
  614.  
  615.         cnop    0,4
  616.  
  617. ************************************************ matchfirst pattern *********
  618.  
  619. MatchFirst    move.l    Pattern(A5),D1        ;get user pattern/file
  620.         lea    Anchorpath(A5),A2    ;get anchorpath
  621.         move.l    A2,D2            ;used for matching
  622.         movea.l    DOSBase(A5),A6        ;set dos_base
  623.         jsr    _LVOMatchFirst(A6)    ;use dos for matchfirst
  624.         move.l    D0,D1            ;get returncode
  625.         beq.b    .skip            ;branch if ok
  626.  
  627.         addq    #4,SP            ;clear return_address
  628.         pea    Quit2(pc)        ;set new one
  629.  
  630. .skip        rts                ;go back
  631.  
  632. *****************************************************************************
  633.  
  634.         cnop    0,4
  635.  
  636. ************************************************ prepare anchorpath *********
  637.  
  638. InitAPath    moveq    #00,D0            ;prepare register
  639.         bset    #SIGBREAKB_CTRL_C,D0    ;do break on <CTRL><C> !!!
  640.         move.l    D0,ap_BreakBits(A5)    ;set bit
  641.  
  642.         bset    #APB_DOWILD,ap_Flags(A5)
  643. *        bset    #APB_DODIR,ap_Flags(A5)
  644. *        bset    #APB_DODOT,ap_Flags(A5)
  645.  
  646.         move.w    #256,ap_Strlen(A5)    ;set length of string_buffer
  647.         rts                ;go back
  648.  
  649. *****************************************************************************
  650.  
  651.         cnop    0,4
  652.  
  653. *****************************************************************************
  654.  
  655. IsFileSystem    movea.l    Pattern(A5),A1
  656.         move.l    A1,D1
  657. .compare    cmp.b    #":",(A1)+
  658.         beq.b    .GetFileSystem
  659.         tst.b    (A1)
  660.         bne.b    .compare
  661.         rts
  662.  
  663. .GetFileSystem    movea.l    A1,A2
  664.         move.b    (A1),D7
  665.         clr.b    (A1)
  666.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  667.         jsr    _LVOIsFileSystem(A6)    ;use DOS to get filesystem
  668.         move.b    D7,(A2)
  669.  
  670.         tst.l    D0            ;get returncode
  671.         beq    Error7            ;branch if ok
  672.  
  673.         rts                ;go back
  674.         
  675. *****************************************************************************
  676.  
  677.         cnop    0,4
  678.  
  679. *****************************************************************************
  680.  
  681. GetDiskInfo    lea    PathName(A5),A1        ;get name
  682.         move.l    A1,D1            ;set name
  683.         moveq    #ACCESS_READ,D2        ;set type
  684.         movea.l    DOSBase(A5),A6        ;set DOS to call a function
  685.         jsr    _LVOLock(A6)        ;use DOS to (lock) file
  686.         move.l    D0,D7            ;save lock (temp.)
  687.  
  688.         move.l    D0,D1            ;set lock
  689.         lea    InfoData(A5),A2        ;get parameterblock
  690.         move.l    A2,D2            ;set parameterblock
  691.         jsr    _LVOInfo(A6)        ;read diskinfo
  692.  
  693.         move.l    D7,D1            ;set lock
  694.         jsr    _LVOUnLock(A6)        ;unlock file
  695.  
  696.         move.l    BytesPerBlock(A5),D0
  697.         move.l    D0,D2
  698.         move.l    D0,D3
  699.         moveq    #0,D1
  700.         bset    #9,D1
  701. .sub        sub.l    D1,D0
  702.         bcc.b    .sub
  703.         neg.l    D0
  704.         cmp.l    D0,D1
  705.         beq.b    .saveBS
  706.         add.l    D0,D2
  707. .saveBS        move.l    D2,BlockSize(A5)
  708.  
  709.         sub.l    #224,D2
  710.         lsr.l    #2,D2
  711.         move.l    D2,ExtBlocks(A5)
  712.         bclr    #9,D1
  713.         moveq    #1,D0
  714. .add        add.l    D3,D1
  715.         sub.l    D0,D2
  716.         bne.b    .add
  717.         move.l    D1,ExtSize(A5)
  718.         rts
  719.  
  720. *****************************************************************************
  721.  
  722.         cnop    0,4
  723.  
  724. *********************************************** read user arguments *********
  725.  
  726. ReadArgs    lea    ExtHelp(pc),A0        ;get rdargs_exthelp
  727.         lea    Template(pc),A1        ;get template
  728.         lea    ArgArray(A5),A2        ;get arg_array
  729.         lea    RDAStruct(A5),A3    ;get rdargs data structure
  730.         move.l    A0,RDA_ExtHelp(A3)    ;set extented help
  731.         move.l    A1,D1            ;set arg_template
  732.         move.l    A2,D2            ;set array
  733.         move.l    A3,D3            ;set rdargs data structure
  734.         movea.l    DOSBase(A5),A6        ;set dos_base
  735.         jsr    _LVOReadArgs(A6)    ;use dos to readargs
  736.         move.l    D0,RDArgs(A5)        ;save returncode
  737.         beq    Error1            ;branch on wrong args
  738.         rts                ;else, go back
  739.  
  740.  
  741. *****************************************************************************
  742.  
  743.         cnop    0,4
  744.  
  745. ************************************************ check arguments ************
  746.  
  747. CheckArgs    moveq    #116,D1            ;"required args miss..."
  748.         move.l    Pattern(A5),D0        ;pattern there ?
  749.         or.l    All(A5),D0        ;all-flag set ?
  750.         beq.b    Error6            ;branch if not
  751.         rts                ;go back
  752.  
  753. *****************************************************************************
  754.  
  755.         cnop    0,4
  756.  
  757. ************************************************ free argument buffer *******
  758.  
  759. FreeArgs    move.l    RDArgs(A5),D1        ;get arg_structure
  760.         beq.b    .skip            ;branch if not set
  761.         move.l    DOSBase(A5),A6        ;set dos_base
  762.         jsr    _LVOFreeArgs(A6)    ;use dos to freeargs
  763. .skip        rts                ;go back
  764.  
  765. *****************************************************************************
  766.  
  767.         cnop    0,4
  768.  
  769. ************************************************ error handling *************
  770.  
  771. Error7        move.l    #225,D1            ;result_2 "not a valid dos.."
  772.         addq    #4,SP            ;clear return_address
  773.         bra.b    Error5
  774.  
  775. ************************************************
  776.  
  777.         cnop    0,4
  778.  
  779. ************************************************
  780.  
  781. Error6        move.l    D1,RCode2(A5)        ;set errorcode
  782.         addq.l    #4,SP            ;clear return_address
  783.         bra.b    Error            ;print error
  784.  
  785. ************************************************
  786.  
  787.         cnop    0,4
  788.  
  789. ************************************************
  790.         
  791. Error5        move.l    D1,RCode2(A5)        ;set errorcode
  792.         pea    Quit0(pc)        ;set return_address
  793.         bra.b    Error            ;print error
  794.  
  795. ************************************************
  796.  
  797.         cnop    0,4
  798.  
  799. ************************************************
  800.  
  801. Error2        addq    #4,SP            ;clear return_address
  802.         pea    Quit0(pc)        ;set new one
  803.         bra.b    Error0            ;print error
  804.  
  805. ************************************************
  806.  
  807.         cnop    0,4
  808.  
  809. ************************************************
  810.  
  811. Error1        addq    #4,SP            ;clear return_address
  812.  
  813. ************************************************
  814.  
  815. Error0        movea.l    DOSBase(A5),A6        ;set dos_base
  816.         jsr    _LVOIoErr(A6)        ;use dos to get ioerr
  817.         move.l    D0,RCode2(A5)        ;save as pr_result2
  818.  
  819. ************************************************
  820.  
  821. Error        move.l    RCode2(A5),D1        ;get errorcode
  822.         movea.l    DOSBase(A5),A6        ;set dos_base
  823.         jsr    _LVOSetIoErr(A6)    ;use dos to set pr_result2
  824.  
  825. *        tst.b    Quick(A5)        ;do all Quick ?
  826. *        bne.b    .SetRCode1        ;branch if so
  827.  
  828.         move.l    RCode2(A5),D1        ;get errorcode
  829.         moveq    #0,D2
  830.  
  831.         cmp.w    #304,D1            ;"***Break"
  832.         beq.b    .skip
  833.  
  834.         lea    Header(pc),A2        ;get head_text 'ERROR:'
  835.         move.l    A2,D2            ;set header
  836.  
  837. .skip        jsr    _LVOPrintFault(A6)    ;use dos to printfault
  838.  
  839. .SetRCode1    moveq    #5,D0            ;set returncode rc=warn
  840.         move.l    D0,RCode1(A5)        ;save
  841.         rts                ;go back
  842.  
  843. *****************************************************************************
  844.  
  845. ExtHelp  
  846.  
  847.  dc.b $A
  848.  
  849.  dc.b "Entries V1.6 by Joerg Riemer Aug'03",$A
  850.  
  851.  dc.b $A
  852.  
  853.  dc.b "         PATTERN/A: path/pattern to examine",$A
  854.  dc.b "             ALL/S: examine all sub-directories",$A
  855.  dc.b "       NS=NOSTAT/S: don't print statistic",$A
  856.  dc.b "    ME=MARKEMPTY/S: mark/print path/filename of empty files",$A
  857.  dc.b "         Q=QUICK/S: don't print any path/filename",$A
  858.  dc.b "  LF=LARGESTFILE/S: print path/filename of largest file",$A
  859.  
  860.  dc.b $A
  861.  
  862. Template dc.b "PATTERN/A,ALL/S,NS=NOSTAT/S,ME=MARKEMPTY/S,Q=QUICK/S,LF=LARGESTFILE/S",0
  863. Header   dc.b "ERROR",0
  864.  
  865. *****************************************************************************
  866.  
  867.         if    BSS_Section
  868.  
  869.         SECTION    MatchTest_bss,BSS
  870.  
  871.         elseif
  872.  
  873.         cnop    0,4
  874.  
  875.         endc
  876.  
  877. *****************************************************************************
  878.  
  879. DataBase    ds.b    BSS_Size
  880.  
  881.  end of source **************************************************************
  882.